package com.ruike.alisurface.https;

import com.ruike.alisurface.Constant;
import com.ruike.alisurface.service.MyScrennService;
import com.ruike.alisurface.utils.ShareKey;
import com.voodoo.lib_http.ApiListener;
import com.voodoo.lib_http.ApiTools;
import com.voodoo.lib_utils.DeviceUtils;
import com.voodoo.lib_utils.SharedUtils;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import static com.ruike.alisurface.Constant.HttpUrl.BASE_URL;
import static com.ruike.alisurface.Constant.HttpUrl.BASE_URL_IP;

public class MchApiHttp {


    public static final String mchUrl = BASE_URL + "MchApi/";//mch 地址
    public static final String mchUrl_IP = BASE_URL_IP + "MchApi/";//mch ip地址
    public static final String orderUrl = BASE_URL + "App/Order/";//订单地址


    public static String geMchBySn = "geMchBySn";// 获取机器信息

    public static String getSlots = "getSlots";// 获取商品列表数据
    public static String getAddLog = "addlog";//  上传日志接口

    public static String confirm_cmd = BASE_URL_IP + "/MchAdminApi/confirm_cmd";


    /**
     * 获取机器信息
     *
     * @param mApiListener 回调
     */
    public static void getMchBySn(ApiListener mApiListener) {
        Map<String, Object> map = new HashMap<>();
        map.put("SN", DeviceUtils.getDeviceSn());
        ApiTools.getInstance().get(mchUrl + geMchBySn, map, mApiListener);
    }

    /**
     * 获取商品列表数据
     *
     * @param mApiListener 回调
     */
    public static void getSlots(ApiListener mApiListener) {
        Map<String, Object> map = new HashMap<>();
        map.put("mchid", SharedUtils.getInstance().getString(ShareKey.MCH_ID));
        ApiTools.getInstance().get(mchUrl + getSlots, map, mApiListener);
    }

    /**
     * 获取 支付结果
     *
     * @param mApiListener 回调
     */
    public static void getPayResult(ApiListener mApiListener, String OrderId) {
        Map<String, Object> map = new HashMap<>();
        map.put("OrderId", OrderId);
        ApiTools.getInstance().get(orderUrl + "getPayResult", map, mApiListener);
    }

    /**
     * 确认出货完成
     * /app/order/OrderIsEnd
     */

    public static void getOrderIsEnd(ApiListener mApiListener, HashMap<String, Object> map) {
        ApiTools.getInstance().get(orderUrl + "OrderIsEnd", map, mApiListener);
    }

    /**
     * 确认出货完成
     * /app/order/OrderIsEnd
     */

    public static void getConfirm_cmd(ApiListener mApiListener, File file) {
        Map<String, Object> map = new HashMap<>();

        map.put("cmd_id", SharedUtils.getInstance().getString("cmd_id", ""));

        ApiTools.getInstance().get(mchUrl + "AddScreenshot", map, mApiListener);
    }

    /**
     * 上传截图
     * /app/order/OrderIsEnd
     */

    public static void getAddScreenshot(ApiListener mApiListener, File file) {
        Map<String, Object> map = new HashMap<>();
        map.put("mchid", SharedUtils.getInstance().getString(ShareKey.MCH_ID, ""));
        map.put("cmd_id", SharedUtils.getInstance().getString("cmd_id", ""));
        map.put("file", file);
        String url = BASE_URL_IP + "/MchApi/AddScreenshot";
        ApiTools.getInstance().post(url, map, mApiListener);
    }


    /**
     * 请求后台开启电控锁
     *
     * @param apiListener 回调
     */
    public static void getDoorlock(ApiListener apiListener, String boxno) {
        String url = BASE_URL_IP + "MchAdminApi/send_open_lock";
        Map<String, Object> map = new HashMap<>();
        map.put("mchid", SharedUtils.getInstance().getString(ShareKey.MCH_ID, ""));
        map.put("uid", SharedUtils.getInstance().getString(ShareKey.UID, ""));
        map.put("boxno", boxno);
        ApiTools.getInstance().get(url, map, apiListener);
    }

    /**
     * 上传网络信号
     *
     * @param apiListener 回调
     */
    public static void getSignal_Intensity(int Signal ,ApiListener apiListener ) {
        Map<String, Object> params = new HashMap<>();
        params.put("mchid", SharedUtils.getInstance().getString(ShareKey.MCH_ID));


        params.put("value", Signal  );
        ApiTools.getInstance().get(BASE_URL_IP+"MchApi/submit_signal_intensity", params, apiListener);
    }


}
